php get filename without extension

If you are looking for how to get filename without extension then there is no need to do any coding or any logic for getting filename without extension simply you can use the php inbuilt function “pathinfo”.This function will return array with file info like extension,Filename without extension,Basename etc.For more info please refer bellow given example.

$path_parts = pathinfo('/www/htdocs/index.html');

echo $path_parts['dirname'], "\n";
echo $path_parts['basename'], "\n";
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n"; // since PHP 5.2.0

will output like

  /www/htdocs
  index.html
  html
  index